/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormSettings.java
 *
 * Created on 15-Dec-2011, 13:29:47
 */
package jmediaplayer;

import com.almworks.sqlite4java.SQLiteConnection;
import com.almworks.sqlite4java.SQLiteException;
import java.awt.Color;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author dean.williams
 */
public class FormSettings extends javax.swing.JFrame {

	/** Creates new form FormSettings */
	public FormSettings() {
		initComponents();

		checkDuplicates.setSelected(setting.getB("allowDuplicates"));

		doCheckDuplicates();
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        duplicateChecked = new javax.swing.ButtonGroup();
        jDialog1 = new javax.swing.JDialog();
        CloseForm = new javax.swing.JButton();
        LabelSettingsTitle = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel1 = new javax.swing.JPanel();
        checkDuplicatesInnerIgnore = new javax.swing.JRadioButton();
        checkDuplicatesInnerAsk = new javax.swing.JRadioButton();
        checkDuplicatesInnerDelete = new javax.swing.JRadioButton();
        checkDuplicatesInnerLabel = new javax.swing.JLabel();
        checkDuplicates = new javax.swing.JCheckBox();

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Settings");
        setAlwaysOnTop(true);

        CloseForm.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/close.png"))); // NOI18N
        CloseForm.setBorder(null);
        CloseForm.setBorderPainted(false);
        CloseForm.setContentAreaFilled(false);
        CloseForm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CloseFormActionPerformed(evt);
            }
        });

        LabelSettingsTitle.setFont(new java.awt.Font("Cooper Black", 0, 24));
        LabelSettingsTitle.setText("Settings");

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        duplicateChecked.add(checkDuplicatesInnerIgnore);
        checkDuplicatesInnerIgnore.setText("Ignore.");
        checkDuplicatesInnerIgnore.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkDuplicatesInnerIgnoreActionPerformed(evt);
            }
        });

        duplicateChecked.add(checkDuplicatesInnerAsk);
        checkDuplicatesInnerAsk.setText("Ask.");

        duplicateChecked.add(checkDuplicatesInnerDelete);
        checkDuplicatesInnerDelete.setText("Delete.");

        checkDuplicatesInnerLabel.setText("Action to take when duplicate found:");

        checkDuplicates.setText("Check for duplicates.");
        checkDuplicates.setToolTipText("Check for duplicate media using the file hash.");
        checkDuplicates.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkDuplicatesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(checkDuplicatesInnerAsk)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(checkDuplicatesInnerIgnore)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(checkDuplicatesInnerDelete))
                            .addComponent(checkDuplicatesInnerLabel)))
                    .addComponent(checkDuplicates))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(checkDuplicates)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(checkDuplicatesInnerLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(checkDuplicatesInnerAsk)
                    .addComponent(checkDuplicatesInnerIgnore)
                    .addComponent(checkDuplicatesInnerDelete))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(LabelSettingsTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(CloseForm))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 417, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(LabelSettingsTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(CloseForm, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(250, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void CloseFormActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CloseFormActionPerformed
    dispose();
}//GEN-LAST:event_CloseFormActionPerformed

private void checkDuplicatesInnerIgnoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkDuplicatesInnerIgnoreActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_checkDuplicatesInnerIgnoreActionPerformed

private void checkDuplicatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkDuplicatesActionPerformed
	//Fire the check
	doCheckDuplicates();

	setting.setB("allowDuplicates", checkDuplicates.isSelected());

}//GEN-LAST:event_checkDuplicatesActionPerformed

public void doCheckDuplicates() {
	if (checkDuplicates.isSelected()) {
		//Enable inner-options
		checkDuplicatesInnerLabel.setForeground(new Color(Integer.parseInt( "000000",16)));
		checkDuplicatesInnerAsk.setForeground(new Color(Integer.parseInt( "000000",16)));
		checkDuplicatesInnerDelete.setForeground(new Color(Integer.parseInt( "000000",16)));
		checkDuplicatesInnerIgnore.setForeground(new Color(Integer.parseInt( "000000",16)));
		checkDuplicatesInnerAsk.setEnabled(true);
		checkDuplicatesInnerDelete.setEnabled(true);
		checkDuplicatesInnerIgnore.setEnabled(true);
	} else {
		//Disable inner-options
		checkDuplicatesInnerLabel.setForeground(new Color(Integer.parseInt( "cbcbcb",16)));
		checkDuplicatesInnerAsk.setForeground(new Color(Integer.parseInt( "cbcbcb",16)));
		checkDuplicatesInnerDelete.setForeground(new Color(Integer.parseInt( "cbcbcb",16)));
		checkDuplicatesInnerIgnore.setForeground(new Color(Integer.parseInt( "cbcbcb",16)));
		checkDuplicatesInnerAsk.setEnabled(false);
		checkDuplicatesInnerDelete.setEnabled(false);
		checkDuplicatesInnerIgnore.setEnabled(false);
	}

	//add to the DB

}
	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[]) {
		/* Set the Nimbus look and feel */
		//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
		 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
		 */
		try {
			for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					javax.swing.UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(FormSettings.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(FormSettings.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(FormSettings.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} catch (javax.swing.UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(FormSettings.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		}
		//</editor-fold>

		/* Create and display the form */
		java.awt.EventQueue.invokeLater(new Runnable() {

			public void run() {
				new FormSettings().setVisible(true);
			}
		});
	}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CloseForm;
    private javax.swing.JLabel LabelSettingsTitle;
    private javax.swing.JCheckBox checkDuplicates;
    private javax.swing.JRadioButton checkDuplicatesInnerAsk;
    private javax.swing.JRadioButton checkDuplicatesInnerDelete;
    private javax.swing.JRadioButton checkDuplicatesInnerIgnore;
    private javax.swing.JLabel checkDuplicatesInnerLabel;
    private javax.swing.ButtonGroup duplicateChecked;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    // End of variables declaration//GEN-END:variables
}
